/** @ingroup vtparser
 * @file vtparser_table.h
 * @brief state table and functions for the vtparser
 *
 * an implementation of [Paul Williams' DEC compatible state machine
 * parser](http://www.vt100.net/emu/dec_ansi_parser) written by Joshua Haberman
 *
 * @author Joshua Haberman <joshua@reverberate.org>
 * @author _modified by_ cameris <camerisdump@gmail.com>
 */

#ifndef TABLE_H
#define TABLE_H

#include <stdint.h>

/** @brief states */
enum vtparse_state {
   VTPARSE_STATE_ANYWHERE = 0,
   VTPARSE_STATE_CSI_ENTRY = 1,
   VTPARSE_STATE_CSI_IGNORE = 2,
   VTPARSE_STATE_CSI_INTERMEDIATE = 3,
   VTPARSE_STATE_CSI_PARAM = 4,
   VTPARSE_STATE_DCS_ENTRY = 5,
   VTPARSE_STATE_DCS_IGNORE = 6,
   VTPARSE_STATE_DCS_INTERMEDIATE = 7,
   VTPARSE_STATE_DCS_PARAM = 8,
   VTPARSE_STATE_DCS_PASSTHROUGH = 9,
   VTPARSE_STATE_ESCAPE = 10,
   VTPARSE_STATE_ESCAPE_INTERMEDIATE = 11,
   VTPARSE_STATE_GROUND = 12,
   VTPARSE_STATE_OSC_STRING = 13,
   VTPARSE_STATE_SOS_PM_APC_STRING = 14,
};

/** @brief actions */
enum vtparse_action {
   VTPARSE_ACTION_CLEAR = 1,
   VTPARSE_ACTION_COLLECT = 2,
   VTPARSE_ACTION_CSI_DISPATCH = 3,
   VTPARSE_ACTION_ESC_DISPATCH = 4,
   VTPARSE_ACTION_EXECUTE = 5,
   VTPARSE_ACTION_HOOK = 6,
   VTPARSE_ACTION_IGNORE = 7,
   VTPARSE_ACTION_OSC_END = 8,
   VTPARSE_ACTION_OSC_PUT = 9,
   VTPARSE_ACTION_OSC_START = 10,
   VTPARSE_ACTION_PARAM = 11,
   VTPARSE_ACTION_PRINT = 12,
   VTPARSE_ACTION_PUT = 13,
   VTPARSE_ACTION_UNHOOK = 14,
};

extern uint8_t (*STATE_TABLE[15])(uint8_t ch);
extern enum vtparse_action ENTRY_ACTIONS[15];
extern enum vtparse_action EXIT_ACTIONS[15];
#endif
